package com.laihui.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.laihui.activity.R;
import com.laihui.entity.AccountLogList;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by G150T on 2017/7/21.
 */

public class AccountLogAdapter extends RecyclerArrayAdapter {
    public AccountLogAdapter(Context context) {
        super(context);
    }
    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new MoneyRecordDetailViewHolderNew(parent);
    }

    /**
     * Created by G150T on 2017/7/21.
     */

    class MoneyRecordDetailViewHolderNew extends BaseViewHolder<AccountLogList.AccountBean> {

        private LinearLayout ll_month, ll_data;
        private  TextView tv_remark,tv_month, /*tv_money,*/ tv_operation_money,/* tv_use_money, tv_no_use_money,*/
                tv_add_time,tv_State;


        public MoneyRecordDetailViewHolderNew(ViewGroup parent) {
            super(parent, R.layout.item_money_record_detail_new);
            tv_remark = $(R.id.tv_remark);//资金详情
            ll_month =$(R.id.ll_month);//资金详情
            ll_data =$(R.id.ll_data);//资金详情
            //tv_money = $(R.id.tv_money);//总金额
            tv_operation_money = $(R.id.tv_operation_money) ;//操作金额
            //tv_use_money = $(R.id.tv_use_money) ;//可用金额
            //tv_no_use_money = $(R.id.tv_no_use_money) ;//冻结金额
            tv_add_time = $(R.id.tv_add_time);//添加时间
            tv_month = $(R.id.tv_month);//添加时间;
            tv_State = $(R.id.tv_State);;

        }

        @Override
        public void setData(AccountLogList.AccountBean data) {
            super.setData(data);

            if (data.time_remark == 1) {
                tv_month.setText(data.month);
                ll_month.setVisibility(View.VISIBLE);
            } else {
                ll_month.setVisibility(View.GONE);
            }
            tv_remark.setText(data.type_cn);

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            long addTime = Long.parseLong(data.addtime);
            DecimalFormat df1= new DecimalFormat("0.00");

            String mark = "";
            if(data.flow.equals("frozen"))
                mark = "冻";
            if(data.flow.equals("in"))
                mark = "+";
            if(data.flow.equals("out"))
                mark = "-";
            if(data.flow.equals("col"))
                mark = "待";
            if(data.flow.equals("thaw"))
                mark = "解冻";

            String time = sdf.format(new Date(addTime));
            tv_add_time.setText(time);
            tv_operation_money.setText(data.money + "元");
            tv_State.setText(data.type_cn);
        }
    }


}
